<template>
  <div class="box6">
    <div class="title">
      <p>热门景区排行</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <!-- 图形图标的容器 -->
    <div class="charts" ref="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
let charts = ref()

onMounted(() => {
  let mychart = echarts.init(charts.value)
  mychart.setOption({
    title: {
      text: '景区排行榜',
      left: '50%',
      textStyle: {
        fontSize: 30,
        color: 'green'
      },
      subtext: '各大景区排行',
      subtextStyle: {
        color: 'yellowgreen',
        fontSize: 16
      }
    },
    //布局组件
    grid: {
      left: 20,
      bottom: 20,
      right: 20
    },
    xAxis: [{ type: 'category' }],
    yAxis: [{}],
    series: [
      {
        type: 'bar',
        data: [5, 20, 36, 10, 10, 20, 4],
        showBackground: true,
        backgroundStyle: {
          //底部背景的颜色
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: 'black' // 0% 处的颜色
              },
              {
                offset: 1,
                color: 'blue' // 100% 处的颜色
              }
            ],
            global: false // 缺省为 false
          }
        },
        //柱状图的:图形上的文本标签，
        label: {
          show: true,
          //文字的位置
          position: 'insideTop',
          //文字颜色
          color: 'yellowgreen'
        }
      },
      {
        type: 'line',
        data:  [5, 20, 36, 10, 10, 20, 4],
        smooth: true //平滑曲线
      }
    ]
  })
})
</script>

<style scoped lang="scss">
.box6 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
  margin: 20px 0px;

  .title {
    margin-left: 5px;

    p {
      color: white;
      font-size: 20px;
    }
  }

  .charts {
    height: calc(100% - 30px);
  }
}
</style>
